package pack0902;

import java.net.URL;

public class DemoA {
    public static void main(String[] args) {
        try {
            URL ur1 = new URL("https://www.baidu.com/s?wd=java");
            System.out.println("URL为："+ur1.toString());
            System.out.println("协议为："+ur1.getProtocol());
            System.out.println("验证信息："+ur1.getAuthority());
            System.out.println("文件名及请求参数："+ur1.getFile());
            System.out.println("主机名："+ur1.getHost());
            System.out.println("路径："+ur1.getPath());
            System.out.println("端口："+ur1.getPort());
            System.out.println("默认端口："+ur1.getDefaultPort());
            System.out.println("请求参数："+ur1.getQuery());
            System.out.println("定位位置："+ur1.getRef());
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }
}
